When I started at Cricket, I inherited a large amount of C source code that
had horribly inaccurate file dependency information in its Make file.
Rather than examining 6MB of code by hand, I decided to automate the process
of discovering which files each target #include'd; and what each of these files
in turn #include'd, and so on...
Clearly the solution to this problem lies in the ability to parse a target file
for its header files, and one-by-one opening them and parsing these in turn for
the #include files that they contain. As long as there are #include statements, they must be opened and examined for the header information they might contain. If any one of these files is changed, then clearly the target needs recompilation. Therefore, the file found will be reported as a dependency. When no #include files remain to be opened, the previous file is reexamined for the next #include statement, and the process is continued until no further files are found. At this point the analysis is complete.
The tool I wrote is called Dependency, and it performs the operations described
above. Although still in need of improvements, it works quite nicely, and your comments regarding its evolution would be appreciated.
To my knowledge, Apple has no facility to perform the work of Dependency, and its need is clearly present in large and small software projects alike. If you are confused about just what the heck Dependency does (given my convoluted explanation), I encourage you to try it on your C source code. You'll soon know exactly what it does, and the need for it in your "{MPW}"Tools folder.
To use this tool you may first want to execute the statement:
Alias dpx Dependency
This way dpx becomes your shorthand way of executing Dependency. After that simply type in:
dpx [sourcefile.c]
Note: If your source code (other than Toolbox headers) is spread out across your disk, then your shell variable {CIncludes} should be ammended to contain all the file paths where Dependency can look for #included files.
Let me know if your Make files are improved using Dependency!